package cn.anxingongyou.anxin.service.impl;

import cn.anxingongyou.anxin.entity.WorkerBudget;
import cn.anxingongyou.anxin.mapper.WorkerBudgetMapper;
import cn.anxingongyou.anxin.service.WorkerBudgetService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WorkerBudgetServiceImpl implements WorkerBudgetService {

    private final WorkerBudgetMapper workerBudgetMapper;
    @Autowired
    public WorkerBudgetServiceImpl(WorkerBudgetMapper workerBudgetMapper) {
        this.workerBudgetMapper = workerBudgetMapper;
    }

    @Override
    public int insert(WorkerBudget workerBudget) {
        return workerBudgetMapper.insertSelective(workerBudget);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return workerBudgetMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(WorkerBudget workerBudget) {
        return workerBudgetMapper.updateByPrimaryKeySelective(workerBudget);
    }

    @Override
    public WorkerBudget selectOne(WorkerBudget workerBudget) {
        return workerBudgetMapper.selectOne(workerBudget);
    }

    @Override
    public WorkerBudget selectOneByPrimaryKey(Long id) {
        return workerBudgetMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<WorkerBudget> page(int pageNum, int pageSize, WorkerBudget workerBudget) {
        String orderBy = "id desc";
        PageHelper pageHelper = new PageHelper();
        pageHelper.startPage(pageNum,pageSize,orderBy);
        List<WorkerBudget> list = workerBudgetMapper.select(workerBudget);
        PageInfo<WorkerBudget> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
